<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../lib/jquery/pace-theme-loading-bar.css" />
    <script src="../../../lib/jquery/jquery.min.js"></script>
    <script src="../../../lib/vue/vue.js"></script>
    <script src="../../../res/controller/commonController.js"></script>
    <script src="../../../res/controller/requestController.js"></script>

</head>
<body style="background:url(http://api.zonetry.com/ZONETRY20XAPPWAP/H5/images/bg-water-mark.png) repeat 0px 0px">
<div class="container" id="login">
    <br>
    <br>
    <br>
    
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <div class="panel panel-default">
                <div class="panel-heading">登录众创空间后台</div>
                <div class="panel-body">
                    <div class="form-group">
                        <label>手机号</label>
                        <input type="text" class="form-control" v-model="tel">
                    </div>
                    <div class="form-group">
                        <label>密码</label>
                        <input type="password" class="form-control"  v-model="pass">
                    </div>
                    <select class="form-control">
                        <option>正式服</option>
                        <option>测试服</option>
                    </select>
                    <br>
                    <button type="botton" @click="doLogin()" class="btn btn-block btn-primary">登录</button>
                    <!--    <button type="botton" @click="getPsssword()" class="btn btn-default">加密</button>-->
                    <!--    <button type="botton" @click="getToken()" class="btn btn-default">Token</button>-->
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="../../../lib/jquery/pace.min.js"></script>
<script>
    var login = new Vue({
        el: '#login',
        data: {
            tel: '13461655101',
            pass: '12345678',
            desPass:'',
            request: new requestController()
        },
        mounted:function () {

        },
        // 在 `methods` 对象中定义方法
        methods: {
            getToken:function () {

                this.request.setApiName("/Token");
                this.request.setRequest();
                this.request.post();
                console.log(this.request.getResponse());
            },
            doLogin: function () {
                var _self = this;
                _self.getPsssword();
                _self.getToken();
                var jsonData = {};
                jsonData.countryCode = "+86";
                jsonData.mobile = _self.tel;
                jsonData.password = _self.desPass;
                jsonData.channelID = 1;
                jsonData.appVersion = 100;
                _self.request.setApiName("/User/Logon/Mobile");
                _self.request.setRequest(jsonData);
                _self.request.post();
                var resData = _self.request.getResponse();
                if(resData.uid != null && resData.uid != ''){
                    _self.request.setCache('uid',resData.uid);
                    _self.request.setCache('password',_self.desPass);
                    _self.request.setCache('name',resData.name);
                    console.log(_self.request.getCache('uid'));
                    window.location = '/index.php'
                }
            },
            getPsssword: function () {
                var _self = this;
                console.log(_self.pass);
                var jsonData = {};
                jsonData.source = _self.pass;
                _self.request.setApiName("/Encrypt");
                _self.request.setRequest(jsonData);
                _self.request.post();
                console.log(2);
                var resData = _self.request.getResponse();
                _self.desPass = resData.result;
                console.log(JSON.stringify(resData));
                console.log(1);
            },
            getAllJsonModel:function () {
                $.ajax({
                    type: "get",
                    async:false,
                    url: "/zt.php?s=/home/index/getAllJsonModel",
                    dataType : 'json',
                    success: function(data){
                       
                        for(var i = 0;i<data.length;i++){
                            localStorage[data[i].app+'_'+data[i].model] = JSON.stringify(data[i].json);
                        }
                    },
                    error : function() {
                        alert('All JsonModel 加载失败');
                    }
                });
            }
        }
    })
    login.getAllJsonModel();
</script>
<link rel="stylesheet" href="../../../lib/bootstrap/bootstrap.css">
<script src="../../../lib/bootstrap/bootstrap.js"></script>
</html>